home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / rpg / crossfir.001 / crossfir~ / eutl / debuglib / debuglib.h < prev    next >
C/C++ Source or Header  |  1994-01-14  |  4KB  |  92 lines

  1. #ifndef __debuglib_h
  2. #define __debuglib_h
  3.  
  4. /*
  5.  * The debugging library is intended to allow users to set up debugging on
  6.  * the basis of complete packages, or subgroups of the packages.  It also
  7.  * lets each of the different subgroups have a different value which allows
  8.  * finer gradation among available debugging choices.
  9.  *
  10.  * Debugging values are specified on the command line in the form
  11.  * -D<debug-name>[=value].  If no value is specified, it defaults to 1.
  12.  * A debug name is a colon separated list of packages and subgroups in those
  13.  * packages.  For example, to set debugging on all of tcplib, you could use
  14.  * -Deutl:tcplib
  15.  * To set debugging on only sending messages in tcplib, you could use
  16.  * -Deutl:tcplib:sendmsg
  17.  * The debugging library will attempt to match debugging queries against the
  18.  * most specific value.  If that fails, then more and more general debugging
  19.  * values will be set, e.g. if while executing your program, you check to see
  20.  * if eutl:tcplib:sendmsg debugging is set on.  If that value was not 
  21.  * explicitly set, but the value for eutl:tcplib was, then that value will
  22.  * be returned.
  23.  * Each of the different packages should document what values can be set
  24.  * for debugging purposes.  Failing this, you can set debugging flags on the
  25.  * debugging library which will tell you about the different debugging 
  26.  * values being checked.
  27.  * 
  28.  */
  29.  
  30. /* This function will destructively update argc, argv removing all arguments
  31.    of the form -D<debug-name>[=value] */
  32. void GetDebuggingArguments(int *argc,char **argv);
  33. int GetDebuggingValue(char *debugname);
  34. void SetDebuggingValue(char *debugname,int value);
  35.  
  36. /* The DEBUG macro allows you to easily set up debugging statements.
  37.    Because of the bizarre way in which macros with arbitrary numbers of 
  38.    arguments work, you need to put parenthesis around the format stuff.
  39.    For example, this could be used as
  40.    DEBUG("eutl:debuglib:check",1,
  41.           ("Checking the debugging value of %s",debugname));
  42.    Which would print out the message in the inner parenthesis along with
  43.    information about what the debugvalue and the line and file were to 
  44.    stdout if the debugging value "eutl:debuglib:check" is >= 1.
  45.    There is also a version of this macro called QDEBUG which will not print
  46.    out the information about the debugvalue line and file, it will just
  47.    print what you specified in the format */
  48.  
  49. #define DEBUG(debugname,minval,format) {\
  50.    if (__debuglib_debugging_on &&\
  51.        GetDebuggingValue(debugname)>=(minval)) {\
  52.      printf("DEBUG(debugname=%s,minlevel=%d,curlevel=%d,line=%d,file=%s)\n",\
  53.         debugname,GetDebuggingValue(debugname),(minval),\
  54.         __LINE__, __FILE__);\
  55.      printf format;\
  56.    }\
  57.  }              
  58.  
  59. /* Quiet Debug */
  60. #define QDEBUG(debugname,minval,format) {\
  61.    if (__debuglib_debugging_on &&\
  62.        GetDebuggingValue(debugname)>=(minval)) {\
  63.      printf format;\
  64.    }\
  65.  }              
  66.                     
  67. /* Test Debugging On 
  68.    used like:
  69.    if (TDEBUG("eutl:debuglib:check",1)) 
  70.       CallDumpDataStructureFunction(arg1,arg2,arg3);
  71. */
  72. #define TDEBUG(debugname,minval) \
  73.  (__debuglib_debugging_on && GetDebuggingValue(debugname) >= (minval))
  74.  
  75.  
  76. /* exceptions are used, see errlib for a better description of how to 
  77.    use them */
  78.  
  79. extern char *debuglib_packagever;
  80.  
  81. extern char *debuglib_Ecantcreatetable;
  82. extern char *debuglib_Egeterror; /* Error getting stored value */
  83. /* this will be set to one if there is any debugging currently set.
  84.    this lets you have a faster test without suffering the overhead of a 
  85.    procedure call in the normal case.  (As if that much overhead is really
  86.    that much, but some people worry about this -- anyway, the complexity can
  87.    be hidden in a macro) */
  88. extern int __debuglib_debugging_on;
  89.  
  90. #endif
  91.  
  92.